import {HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom'
import Index from './layout/main/index.jsx'
import Login from './views/login/index.jsx'
import { connect } from 'react-redux'

const App = ({isLogin}) => {
  console.log(isLogin.isLogin)
  return (
    <Router>
      <Switch>
        <Route path="/login" component = { Login } />
        {/* 前端登录验证 */}
        {
          isLogin ? <Route path="/" component = { Index } /> : <Redirect to="/login" />
        }
      </Switch>
    </Router>
  )
}

export default connect(
  state => {
    return {
      isLogin: state.getIn(['user', 'isLogin'])
    }
  }
)(App)
